package com.dsr.practice.wrapper;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class ContentFileReader {
	public String read(String fileName) throws IOException {
		BufferedReader br = null;
		StringBuilder sb = new StringBuilder();
		try {
			br = new BufferedReader(new InputStreamReader(new FileInputStream(
					fileName), "Cp1251"));

			int character;
			while ((character = br.read()) != -1) {
				sb.append((char) character);
			}

		} finally {
			if (br != null) {
				br.close();
			}
		}

		return sb.toString();
	}

	// public static void main(String[] args) throws IOException {
	// String name;
	// for (int i = 0; i < args.length; i++) {
	// name = args[i];
	// BufferedReader br = new BufferedReader(new InputStreamReader(
	// new FileInputStream(name), "Cp1251"));
	// String s;
	// while ((s = br.readLine()) != null) {
	// System.out.println(s);
	// }
	// br.close();
	// }
	// }
}